<?php
	
	abstract class tpl_module extends module {			
		
		public function get_tpl_name(){
			return $this->get_name().".tpl";
		}

		public function fetch() {
			$tpl = context::get("tpl");
			$module_id = context::get("request")->get_module_id();
			
			$__TPL["module_id"] = $module_id;

			$__TPL["FORM"]["module_name"] = "<input type='hidden' name='{$module_id}' value='{$this->get_name()}'>";
			$tpl->assign("__TPL",$__TPL);
			
			$this->exec();
			
			$root = context::get("path")->get_root();
			$tpl_dir = $root._DRS."modules"._DRS.$this->get_name();
			$tpl->set_template_dir($tpl_dir);
			
			return $tpl->fetch($this->get_tpl_name());
		}
		
		public function notify_message($msg){
			$this->notify_error($msg,"notice");
		}

		public function notify_error($msg, $level = "error"){
			context::get("session")->notify_error($msg, $level);
		}
	}


?>
